package tests;

import static org.junit.Assert.*;

import org.junit.Test;

import process.Manager;
import fabrik.Project;

public class runTest
{

	@Test
	public void birthDayPartyTest ()
	{
		Manager manager = new Manager ( "resources/testdaten/Test1" );
		manager.process ();
		Project project = manager.getProject ();
		assertEquals ( 3, project.getProcessById ( 0 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 0 ).getFreePuffer () );
		assertEquals ( 3, project.getProcessById ( 1 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 1 ).getFreePuffer () );
		assertEquals ( 4, project.getProcessById ( 2 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 2 ).getFreePuffer () );
		assertEquals ( 3, project.getProcessById ( 3 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 3 ).getFreePuffer () );
		assertEquals ( 4, project.getProcessById ( 4 ).getTotalPuffer () );
		assertEquals ( 1, project.getProcessById ( 4 ).getFreePuffer () );
		assertEquals ( 3, project.getProcessById ( 5 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 5 ).getFreePuffer () );
	}

	@Test
	public void webServerTest ()
	{
		Manager manager = new Manager ( "resources/testdaten/Test2" );
		manager.process ();
		Project project = manager.getProject ();
		assertEquals ( 3, project.getProcessById ( 0 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 0 ).getFreePuffer () );
		assertEquals ( 3, project.getProcessById ( 1 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 1 ).getFreePuffer () );
		assertEquals ( 3, project.getProcessById ( 2 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 2 ).getFreePuffer () );
		assertEquals ( 3, project.getProcessById ( 3 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 3 ).getFreePuffer () );
		assertEquals ( 3, project.getProcessById ( 4 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 4 ).getFreePuffer () );
	}

	@Test
	public void airportTest ()
	{
		Manager manager = new Manager ( "resources/testdaten/Test3" );
		manager.process ();
		Project project = manager.getProject ();
		assertEquals ( -20, project.getProcessById ( 0 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 0 ).getFreePuffer () );
		assertEquals ( -10, project.getProcessById ( 1 ).getTotalPuffer () );
		assertEquals ( 10, project.getProcessById ( 1 ).getFreePuffer () );
		assertEquals ( -20, project.getProcessById ( 2 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 2 ).getFreePuffer () );
		assertEquals ( -20, project.getProcessById ( 3 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 3 ).getFreePuffer () );
		assertEquals ( 10, project.getProcessById ( 4 ).getTotalPuffer () );
		assertEquals ( 30, project.getProcessById ( 4 ).getFreePuffer () );
		assertEquals ( -20, project.getProcessById ( 5 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 5 ).getFreePuffer () );
		assertEquals ( -20, project.getProcessById ( 6 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 6 ).getFreePuffer () );
	}

	@Test
	public void moveTest ()
	{
		Manager manager = new Manager ( "resources/testdaten/Test4" );
		manager.process ();
		Project project = manager.getProject ();
		assertEquals ( 0, project.getProcessById ( 0 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 0 ).getFreePuffer () );
		assertEquals ( 0, project.getProcessById ( 1 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 1 ).getFreePuffer () );
		assertEquals ( 4, project.getProcessById ( 2 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 2 ).getFreePuffer () );
		assertEquals ( 9, project.getProcessById ( 3 ).getTotalPuffer () );
		assertEquals ( 3, project.getProcessById ( 3 ).getFreePuffer () );
		assertEquals ( 4, project.getProcessById ( 4 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 4 ).getFreePuffer () );
		assertEquals ( 4, project.getProcessById ( 5 ).getTotalPuffer () );
		assertEquals ( 4, project.getProcessById ( 5 ).getFreePuffer () );
		assertEquals ( 4, project.getProcessById ( 6 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 6 ).getFreePuffer () );
		assertEquals ( 18, project.getProcessById ( 7 ).getTotalPuffer () );
		assertEquals ( 18, project.getProcessById ( 7 ).getFreePuffer () );
		assertEquals ( 0, project.getProcessById ( 8 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 8 ).getFreePuffer () );
		assertEquals ( 6, project.getProcessById ( 9 ).getTotalPuffer () );
		assertEquals ( 6, project.getProcessById ( 9 ).getFreePuffer () );
		assertEquals ( 0, project.getProcessById ( 10 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 10 ).getFreePuffer () );
		assertEquals ( 0, project.getProcessById ( 11 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 11 ).getFreePuffer () );
		assertEquals ( 0, project.getProcessById ( 12 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 12 ).getFreePuffer () );
	}

	@Test
	public void houseBuildTest ()
	{
		Manager manager = new Manager ( "resources/testdaten/Test5", "Abriss", "Verkauf" );
		manager.process ();
		Project project = manager.getProject ();
		assertEquals ( 125, project.getProcessById ( 0 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 0 ).getFreePuffer () );
		assertEquals ( 135, project.getProcessById ( 1 ).getTotalPuffer () );
		assertEquals ( 10, project.getProcessById ( 1 ).getFreePuffer () );
		assertEquals ( 55, project.getProcessById ( 2 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 2 ).getFreePuffer () );
		assertEquals ( 55, project.getProcessById ( 3 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 3 ).getFreePuffer () );
		assertEquals ( 55, project.getProcessById ( 4 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 4 ).getFreePuffer () );
		assertEquals ( 55, project.getProcessById ( 5 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 5 ).getFreePuffer () );
		assertEquals ( 125, project.getProcessById ( 6 ).getTotalPuffer () );
		assertEquals ( 70, project.getProcessById ( 6 ).getFreePuffer () );
		assertEquals ( 55, project.getProcessById ( 7 ).getTotalPuffer () );
		assertEquals ( 0, project.getProcessById ( 7 ).getFreePuffer () );
	}

}
